package com.ququ.syb.commission.controller;

import com.ququ.common.result.Result;
import com.ququ.syb.commission.service.CommissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommissionController {
    @Autowired
    private CommissionService commissionService;

    @RequestMapping("/commission/pay/rate/customer")
    public Result<Double> getPayCommissionRate(@RequestParam String paychannelid,
                                               @RequestParam(required = false) String appcode,
                                               @RequestParam(required = false) String accountid,
                                               @RequestParam(required = false) String partner){
        return commissionService.getPayCommissionRate(paychannelid, appcode, accountid, partner);
    }

    @RequestMapping("/commission/pay/customer")
    public Result<Long> getPayCommission(@RequestParam Long amount,
                                         @RequestParam String paychannelid,
                                         @RequestParam(required = false) String appcode,
                                         @RequestParam(required = false) String accountid,
                                         @RequestParam(required = false) String partner){
        return commissionService.getPayCommission(amount, paychannelid, appcode, accountid, partner);
    }

    @RequestMapping("/commission/pay/cost")
    public Result<Long> getPayCostCommissionRate(@RequestParam Long amount,
                                                 @RequestParam String paychannelid){
        return commissionService.getPayCostCommission(amount, paychannelid);
    }

    @RequestMapping("/commission/withdraw/customer")
    public Result<Long> getWithdrawCommission(@RequestParam Long amount,
                                              @RequestParam String paychannelid,
                                              @RequestParam(required = false) String appcode,
                                              @RequestParam(required = false) String accountid){
        return commissionService.getWithdrawCommission(amount, paychannelid, appcode, accountid);
    }

    @RequestMapping("/commission/withdraw/cost")
    public Result<Long> getWithdrawCostCommission(@RequestParam Long amount,
                                                  @RequestParam String paychannelid,
                                                  @RequestParam Integer withdrawtype){
        return commissionService.getWithdrawCostCommission(amount, paychannelid, withdrawtype);
    }
}
